<template>
  <view>
    <view class="bg-gradual-blue top_content">
      <!-- header开始 -->
      <view class="flex padding-lr-lg padding-tb-xl">
        <view class="basis-xst">
          <open-data type="userAvatarUrl"></open-data>
        </view>
        <view class="padding-left-lg" style="margin-right:auto;">
          <button
            v-if="!isFirstLogin"
            class="cu-btn bg-orange margin-top"
            open-type="getUserInfo"
            @click="checkStorage"
          >微信授权</button>
          <block v-else>
            <view class="text-black">
              <open-data type="userNickName"></open-data>
            </view>
            <view class="margin-top-sm text-red">个人认证</view>
          </block>
        </view>
        <view>积分：{{0}}</view>
      </view>
      <!-- header结束 -->
    </view>

    <!-- <view>{{openid}}</view> -->
    <!-- 我的列表开始 -->
    <view class="container">
      <view class="container_lists">
        <view class="container_lists_list" v-for="(item,index) in myCenterListData" :key="item" @click="goNewPage(index)">
			{{item}}
		</view>
      </view>
    </view>
    <!-- 我的列表结束 -->
  </view>
</template>


<script>
import avatar from "@/components/avatar.vue";
import service from "../../service.js";
import { mapState } from "vuex";

export default {
  data() {
    return {
      avatarImgUrl: "../../static/logo.png",
      userName: "",
      isFirstLogin: false,
	  openid: "",
	  // 列表事件
	  myCenterListData:['我的发布','我的行业','我的活动','我的好友','我的帖子','账单钱包','发现','设置']
    };
  },
  onLoad() {
    this.openid = uni.getStorageSync("opid");

    const flag = uni.getStorageSync("isFirstLogin");
    this.isFirstLogin = flag;

    this.init();

  },
  computed: {
    // 是否登录
  },
  methods: {
	  
	  // 跳转新页面
	  goNewPage(index){
      let a 
		  if(index == 0) a = '../myCenterListS/myReleases';
		  uni.navigateTo({
			url: a
		})
	  },
	
    checkStorage() {
      const flag = uni.getStorageSync("isFirstLogin");
      this.isFirstLogin = flag;
      if (!flag) {
        uni.showModal({
          title: "提示",
          content: "还未登录，请登录",
          success: res => {
            if (res.confirm) {
              uni.navigateTo({
                url: "../login/login"
              });
            }
          }
        });
      } else {
        uni.switchTab({
          url: "pages/user/user"
        });
      }
    },
    init() {
      uni.request({
        url: "https://wechat.lccmart.com/ygy/api/wechatapi/get_userinfo",
        data: {
          openid: uni.getStorageSync("opid")
        },
        success: res => {
          console.log(res);
        }
      });
    }
  },
  components: {
    avatar
  }
};
</script>

<style lang="less" scoped>
.top_content {
  font-size: 28rpx;
  .basis-xst {
    border-radius: 50%;
    overflow: hidden;
    width: 100rpx;
    height: 100rpx;
  }
}
.container {
  color: black;
  .container_lists {
	  font-size: 24rpx;
	  justify-content: space-around;
	flex-wrap: wrap;
    .container_lists_list {
		background: white;
		margin-top: 10rpx;
		padding: 20rpx 20rpx;

		img{
			width: 80rpx;
			height: 80rpx;
		}
    }
  }
}
</style>
